home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_200
/
249_01
/
csrdemo.c
< prev
next >
Wrap
Text File
|
1987-10-27
|
31KB
|
776 lines
/*
** C S R D E M O . C
**
** This is a program to demonstrate the use and power of the C Spot Run
** C Add-On Library. C Spot Run (CSR) is a large library of routines and
** programming aids for C programmers who work in the IBM-PC environment.
** Windowing, screen control, directory access, printer control, BIOS and
** DOS interfaces, and sophisticated data input are just a few of the many
** features of this package.
** C Spot Run is a user-supported package, distributed as "Shareware."
** Users may register to receive source code and updates for $50, and a
** license to use CSR commercially is available for $75, which includes all
** the benefits of normal registration. A $15 donation is requested, in
** exchange for update notifications, from those who use CSR but don't need
** source code.
**
** This program is designed to work with Version 2.1 of CSR, available on
** the BBS listed below and from various BBS's around the United States and
** Canada.
**
** Copyright 1987 Bob Pritchett. All Rights Reserved.
**
** 07/12/87 RDP Some more work on options, including the windows demo.
**
** 07/09/87 RDP Working on more options.
**
** 07/05/87 RDP More work, with sound and new menu routines.
**
** 06/18/87 RDP Coding begun. Total replacement of CSRPROMO.C.
**
** New Dimension Software
** 23 Pawtucket Dr.
** Cherry Hill, NJ 08003
** Voice: (609) 424-2595
** Data: (609) 354-9259 (300/1200/2400B)
**
*/
/* --------------- Include Files ------------------- */
#include <dos.h> /* For int86() */
#include <color.h> /* Color Code Definitions */
#include <csrsound.h> /* Note Values */
#include <csrmisc.h> /* Miscellaneous CSR Definitions */
#include <skey.h> /* Special Key Values */
/* --------------- Defined Values ----------------- */
#define NULL 00 /* Define NULL for Readability */
#define MENOPTS 10 /* Number of Options on Menu */
/* --------------- Menu Definition ---------------- */
static char *mmenu[MENOPTS] =
{
"General Information",
"-Specifics Follow", /* Line With Comment */
"Windows",
"Sound",
"Menuing",
"Directory Access",
"Input",
"Other Features",
"-More Info",
"New Dimension Software"
};
/* --------------- Global Variables --------------- */
static int c; /* Character Input */
static int sw; /* Status Window */
static int hw; /* Help Window */
static int x; /* Do it all Variable */
static int sc; /* Saved Cursor */
static int mm; /* Main Menu Pointer */
static int dtw; /* Date and Time Window */
static int cbflag = 0; /* Control-Break Detect Flag */
static int dt = 0; /* Type for DateTime Update */
static char name[40]; /* Name for Mailing List */
static char title[40]; /* Title for Mailing List */
static char company[40]; /* Company for Mailing List */
static char address[40]; /* Address for Mailing List */
static char city[40]; /* City for Mailing List */
static char state[40]; /* State for Mailing List */
static char zip[40]; /* Zip for Mailing List */
static char phone[40]; /* Phone for Mailing List */
static char comment[40]; /* Comment for Mailing List */
/* --------------- Program Code ------------------- */
wait_cr() /* Wait for a Carriage Return */
{
while ( 1 ) /* Forever */
{
if ( kbhit() ) /* If Keyboard Hit */
if ( getch() == 13 ) /* If A Carriage Return */
break; /* Break Out of Loop */
if ( cbflag ) /* If Control Break Hit */
handcb(); /* Handle It */
}
}
updt_cr() /* Update Until Carriage Return */
{
while ( 1 ) /* Forever */
{
dtupdate(); /* Update Time and Date */
if ( getch() == 13 ) /* If A Carriage Return */
break; /* Break Out of Loop */
}
}
dtupdate() /* Update Date and Time */
{
int d,mn,y;
int h,m,s,hs;
char tmp[40];
while ( ! kbhit() )
{
get_date(&d,&mn,&y);
get_time(&h,&m,&s,&hs);
sprintf(tmp," Date: %02d/%02d/%d",mn,d,(y-1900));
gotoxy(2,62); /* We don't want to activate the window */
ccputs(tmp,BLK_F+GRN_B); /* for this update, because of the constant */
sprintf(tmp," Time: %02d:%02d:%02d",h,m,s); /* change from the menu to */
gotoxy(3,62); /* here. (We want to eliminate unnecessary */
ccputs(tmp,BLK_F+GRN_B); /* window manipulation in this situation.) */
if ( cbflag ) /* If Control-Break Hit */
handcb(); /* Handle It */
if ( dt ) /* If Type 1 */
break; /* Don't Wait for Key */
}
}
main()
{
sc = save_cursor(); /* Save the Cursor Position */
save_screen(); /* Save the Screen */
cursor_off(); /* Send the Cursor Bye-Bye */
cls(); /* Clear to Black and White */
cbcapt(&cbflag); /* Capture Control-Break */
color(WHT_F+RED_B); /* Set Output Colors */
hw = wopen(20,6,24,74,2); /* Open Help Window */
helpwin(0); /* Display Help Set Zero */
color(BLK_F+GRN_B); /* Set Output Colors */
dtw = wopen(1,61,4,78,1); /* Open Date and Time Window */
pmfunc(dtupdate); /* Set Update Function */
mm = pmopen(6,26,"┤ Main Menu ├",MENOPTS,mmenu,1); /* Open Menu */
while ( 1 ) /* Forever */
{
x = pmrun(mm); /* Run Main menu */
cursor_off(); /* Cursor Turned on by pmrun() */
if ( x == -1 ) /* If He/She Wants to Exit */
break; /* Go Right Ahead and Break Out */
switch ( x ) /* Process Option */
{
case 0: /* "General Information" */
gi(); /* Display General Info */
break;
case 2: /* "Windowing" */
win(); /* Do Windowing Demo */
break;
case 3: /* "Sound" */
snd(); /* Display Sound Info and Demo */
break;
case 4: /* "Menuing" */
mnuing(); /* Display Menuing Information */
break;
case 5: /* "Directory Access" */
diracc(); /* Display Directory and Info */
break;
case 6: /* "Input" */
inpinf(); /* Display Input Information */
break;
case 7: /* "Other Features" */
ofinf(); /* Display Other Features Info */
break;
case 9: /* "New Dimension Software" */
nds(); /* Display NDS Info */
break;
default: /* Otherwise */
beep(); /* Beep */
continue; /* Continue While Loop */
}
helpwin(0); /* Display Help Set Zero */
}
quit(); /* Quit */
}
helpwin(hs) /* Update Help Window */
int hs; /* Help Text Set */
{
int lv; /* Local Value */
static char *hlp[15] = /* Help Text */
{
"From the main menu you can select the option you'd like",
"by using the up and down arrow keys, space and backspace,",
"or by hitting the first letter of the option's name.",
"",
"Hit the enter key when you are ready to go on.",
"",
"Please provide the requested information in the fields specified",
"and hit the escape key when you are finished. You will then be",
"given an opportunity to print a mailing list application.",
"",
"Hit return to print the form, or <ESC> to return to the menu.",
"",
"",
"Hit any key or wait for the program to continue.",
""
};
wcls(hw); /* Clear Help Window */
for ( lv = 0; lv < 3; ++lv ) /* Three Times */
wcenter(hw,lv,hlp[(hs*3)+lv]); /* Display Help Line */
}
handcb() /* Handle Control Break */
{
int lv; /* Local Value */
beep(); /* Beep for Attention */
color(YEL_F+RED_B); /* Colors that Stand Out */
lv = message("Control-Break Detected: Hit 'Y' to Exit Program",0);
if ( toupper(lv) == 'Y' ) /* If 'Y' Hit */
quit(); /* Quit Program */
cbflag = 0; /* Reset Flag */
}
quit() /* Quit Program */
{
cbrest(); /* Restore Control-Break Handler */
pmclose(mm); /* Close Main Menu */
wclose(dtw); /* Close Date and Time Window */
wclose(hw); /* Close Help Window */
cu